/**
 *@ClassName login
 *@Description
 *@Author JiJiang
 *@Date 2022/10/7 21:12
 *@Version 1.0
 */

$(function () {

    //监听登录按键的点击事件
    $("#btn_login").click(loginBtnOnClick);

});

//登录按键的点击事件
function loginBtnOnClick() {

    let loginResult = MyAjax(`${HOST_BACK}/login`, "POST", $("#form_login").serialize());
    alert(loginResult.msg);

    //如果登录成功
    if (loginResult.msg == "success") {

        //将登录的用户名存入localStorage
        localStorage.setItem(USERNAME_KEY_LOGIN_LOCALSTORAGE, $("#username").val());

        //跳转到index页面
        window.location.href = "/html/message/index.html";
        return;
    }

}